package Controllers;

import PrinterSource.QueryHandler;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class PrinterDetails extends HttpServlet {

    public void doPost(HttpServletRequest request,
            HttpServletResponse response)
            throws IOException, ServletException {




        String printernumber = request.getParameter("PrinterChoice");

        String[] arrayStrings = QueryHandler.get_printer_byName(printernumber);
        if (arrayStrings != null) {
      //
            
            String[] colours = new String[]{arrayStrings[12],arrayStrings[13],arrayStrings[14]};
            request.setAttribute("localisation", arrayStrings[6]);
            request.setAttribute("model", arrayStrings[1]);
            request.setAttribute("maxcapasity", arrayStrings[4]);
            request.setAttribute("remainingcapasity", arrayStrings[5]);
            request.setAttribute("Inklevels", colours);
            request.setAttribute("PrinterNumber", printernumber);
        }
        
        RequestDispatcher view = request.getRequestDispatcher("PrinterDetails.jsp");
        view.forward(request, response);

    }
}
